function getMysql() {
    var host="172.16.3.251"
    var database="coolgua_ems"
    var password="12liumingtai"
    var user="root"
    var port="3306"
    if (!database) {
        throw "请先mock登录系统之后再操作"
    }
    const knex = require('knex')({
        client: 'mysql',
        connection: {
            host, database, password, user, port
        }
    });
    return knex;
}
async function  list() {
    var mysql = await getMysql();
    var taskList = await mysql.table("ems_task").select("*").where({
        "exhibition_id":"94c03036b5de4822af1d7306858642e7",
    })
    taskList=taskList.filter(item=>{
        return item.submit_user_name==null
            ||item.submit_user_name==''
    })
    for (let i = 0; i <taskList.length ; i++) {
        var task=taskList[i]
        var userId=task.user_id
        if(userId){
            //去展商表查找用户
            var one=await mysql.table("ems_exhibitor").first("*").where({
                "id":userId,
                "exhibition_id":"94c03036b5de4822af1d7306858642e7",
            })
            if(one){
                //修改这条task的submit_user_name
                var paramsSelect={
                    exhibition_id:one.exhibition_id,
                    id:task.id
                }
                var _one2=await mysql.table("ems_task").first("*").where(paramsSelect)
                //安全起见 修改之前还是要看看 有咩有这个任务
                if(_one2&&one.company_name){
                    await   mysql.table("ems_task").where({
                        ...paramsSelect
                    }).update({
                        submit_user_name:one.company_name
                    })
                    console.log("跟新了数据",one)
                }

            }
        }
    }

}

function  init() {
    list();
}

init()